<template>
  <div>
    <img class="user-poster" src="https://img.yzcdn.cn/public_files/2017/10/23/8690bb321356070e0b8c4404d087f8fd.png">
    <van-row class="user-links">
      <van-col span="6">
        <van-icon name="pending-payment" />
        待付款
      </van-col>
      <van-col span="6">
        <van-icon name="records" />
        待接单
      </van-col>
      <van-col span="6">
        <van-icon name="tosend" />
        待发货
      </van-col>
      <van-col span="6">
        <van-icon name="logistics" />
        已发货
      </van-col>
    </van-row>

    <van-cell-group class="user-group">
      <van-cell icon="records" title="全部订单" is-link />
    </van-cell-group>

    <van-cell-group>
      <van-cell icon="points" title="我的积分" is-link />
      <van-cell icon="gold-coin-o" title="我的优惠券" is-link />
      <van-cell icon="gift-o" title="我收到的礼物" is-link />
    </van-cell-group>
    <van-divider/>

    <van-button v-if="login" type="danger" size="large" @click="Logout">退出</van-button>
    <van-button v-if="!login" type="primary" size="large" @click="Login">登入</van-button>

  </div>
</template>

<script>
import { Row, Col, Icon, Cell, CellGroup } from 'vant';

import { Toast1s } from "/@//utils/hit.js"
import { ref, onMounted } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { setLocal, getLocal } from '/@//utils/storage.js'

export default {
  components: {
    [Row.name]: Row,
    [Col.name]: Col,
    [Icon.name]: Icon,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup
  },
  setup() {
    const store = useStore()
    const router = useRouter()

    const login = ref(false)

    login.value = getLocal("token")? true : false

    const Logout = () => {
      
      setLocal("token", "")
      Toast1s("退出成功")
      login.value = false
    }

    const Login = () => {
      
      router.push({
        path: "/login"
      })

    }

    onMounted(() => {

    })

    return { Logout, Login, login }
  }
};

</script>

<style lang="less">
.user {
  &-poster {
    width: 100%;
    height: 53vw;
    display: block;
  }

  &-group {
    margin-bottom: 15px;
  }

  &-links {
    padding: 15px 0;
    font-size: 12px;
    text-align: center;
    background-color: #fff;

    .van-icon {
      display: block;
      font-size: 24px;
    }
  }
}
</style>
